package com.jx.cs.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jx.cs.dao.RoleDao;
import com.jx.cs.pojo.Role;
import com.jx.cs.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleDao roleDao;


    //查询全部
    @Override
    public Map<String, Object> selectRole(String rname,Integer page, Integer limit) {
        Page<Role> page1 = PageHelper.startPage(page, limit);
        List<Role> roles = roleDao.selectRole(rname);
        HashMap<String, Object> map = new HashMap<>();
        long total = page1.getTotal();
        map.put("code",0);
        map.put("count",total);
        map.put("data",roles);
        return map;
    }

    /*添加信息*/
    @Override
    public void addRole(Role role) {
        roleDao.addRole(role);

    }

    /*删除信息*/
    @Override
    public void delRole(Integer rid) {
        roleDao.delRole(rid);
    }
}
